<!-- 编辑客户 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>编辑商户</title>
<link rel="stylesheet" href="${base}/static/media/css/bootstrap.css" />
<script src="${base}/static/index/vendor/jquery/jquery.min.js"></script>
<script src="${base}/static/index/vendor/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" charset="utf-8"
	src="${base }/static/vendor/bootstrapPager/bootstrapPager.js"></script>
<script type="text/javascript" charset="utf-8"
	src="${base }/static/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" charset="utf-8"
	src="${base }/static/js/layer/layer.js"></script>
<link href="${base }/static/css/base.css" rel="stylesheet"
	type="text/css" />
<link rel="stylesheet" type="text/css"
	href="${base }/static/css/help.css" />
<script type="text/javascript"
	src="${base }/static/js/jquery-1.8.1.min.js"></script>
<script type="text/javascript">

$(document).ready(function(){
    $("#submitButton").click(function(){
    	var customerName = $("input[name=customerName]").val();//名称
    	var customerPhone = $("input[name=customerPhone]").val();//电话
    	/* var customerDescription = $("input[name=customerDescription]").val();//描述 */
    	var customerDescription = $('#customerDescription').val(); //描述
    	var customerType = $("input[name='customerType']:checked").val();//类型
    	
    	var backByMonth =$("#backByMonth option:selected").val(); //分期数
        var inputOilAmount = $("input[name=inputOilAmount]").val();//充油金额
        var donationAmount = $("input[name=donationAmount]").val();//增送金额
        var id = $("input[name=id]").val();
        
        /* var remarks = $("input[name=remarks]").val();//备注 */
        var remarks = $('#remarks').val(); //备注
        var isCheck = true;
        $('.newmer').each(function(){
            if ($(this).val()=='') {
                layer.msg("*为必填字段,不得为空");
            }
        });
        if($.isNumeric(inputOilAmount)==false){
            layer.msg("请输入正确的金额");
            isCheck = false;
            return false;
        }
        if($.isNumeric(donationAmount)==false){
            layer.msg("请输入正确的金额");
            isCheck = false;
            return false;
        }
        if(isCheck==true){
            layer.confirm('<p>充油金额为:'+inputOilAmount+'</p><p>增送金额为:'+donationAmount+'</p><p>分期数为:'+backByMonth+'</p>确定修改这个订单吗?', {icon: 3, title:'提示'}, function(index){
                layer.close(index);
                $("#submitButton").hide();
                $("#submitShow").show();
                var data = {
                	'id' : id,	
                    'customerName' : customerName,
                    'customerPhone' : customerPhone,
                    'customerDescription' : customerDescription,
                    'customerType' : customerType,
                    'backByMonth' : backByMonth,
                    'inputOilAmount' : inputOilAmount,
                    'donationAmount' : donationAmount,
                    'remarks' : remarks
                }
                $.ajax({
                    url:"${pageContext.request.contextPath}/buyOil/updateClient",
                    type:'post',
                    dataType:'json',
                    data:data,
                    success:function(res)
                    {
                        if(res.code ==1){
                            layer.msg(res.msg, {icon: 1});
                            location.href="${base}/buyOil/clientAll";
                        }else{
                            layer.msg(res.msg, {icon: 5});
                        }
                        $("#submitButton").show();
                        $("#submitShow").hide();
                        $("#orderlist_form")[0].reset();
                    }
                });
                return false;
            });
        }
    });
});

function smalltoBIG(n)     
{    
    var fraction = ['角', '分'];    
    var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];    
    var unit = [ ['元', '万', '亿'], ['', '拾', '佰', '仟']  ];    
    var head = n < 0? '欠': '';    
    n = Math.abs(n);    
  
    var s = '';    
  
    for (var i = 0; i < fraction.length; i++)     
    {    
        s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');    
    }    
    s = s || '整';    
    n = Math.floor(n);    
  
    for (var i = 0; i < unit[0].length && n > 0; i++)     
    {    
        var p = '';    
        for (var j = 0; j < unit[1].length && n > 0; j++)     
        {    
            p = digit[n % 10] + unit[1][j] + p;    
            n = Math.floor(n / 10);    
        }    
        s = p.replace(/(零.)*零$/, '').replace(/^$/, '零')  + unit[0][i] + s;    
    }    
    return head + s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整');    
}
function changeY(){
	
    var inputOilAmount =parseInt($("input[name=inputOilAmount]").val(),10);
    var donationAmount =parseInt($("input[name=donationAmount]").val(),10);
    var totalAssets = inputOilAmount + donationAmount;
	
	var data = smalltoBIG(totalAssets);
	$("#showRMB").text(data);
	$("#showRMB").show();
}

</script>
</head>
<body style="background: #fff; font-size: 14px;">
	<div class="portlet-body">
		<form class="dataform" id="orderlist_form"
			action="" method="post">
			<div class="row" style="height: 15px;"></div>
			<div class="row">
				<label class="col-md-2" style="line-height: 35px;">&nbsp;&nbsp;&nbsp;&nbsp;客户名称&nbsp;<b
					style="color: red; font-size: 16px;">*</b>：
				</label>
				<div class="col-md-3">
					<input type="text" class="form-control newmer" name="customerName"
						placeholder="请输入姓名" value="${order.customerName}" id="">
				</div>
			</div>
			<div class="row" style="height: 10px;"></div>
			<div class="row">
				<label class="col-md-2" style="line-height: 35px;">&nbsp;&nbsp;&nbsp;&nbsp;客户电话&nbsp;<b
					style="color: red; font-size: 16px;">*</b>：
				</label>
				<div class="col-md-3">
					<input type="text" class="form-control newmer" name="customerPhone"
						placeholder="请输入电话号码" value="${order.customerPhone}" id="">
					<input type="hidden" name="id" value="${order.id}">
				</div>
			</div>
			<div class="row" style="height: 10px;"></div>
			<div class="row">
				<label class="col-md-2" style="line-height: 35px;">&nbsp;&nbsp;&nbsp;&nbsp;用油描述&nbsp;<b
					style="color: red; font-size: 16px;">*</b>：
				</label>
				<div class="col-md-3">
					<textarea rows="5" cols="41" name="customerDescription"
						id="customerDescription" >
						${order.customerDescription}
                        </textarea>
				</div>
			</div>
			<div class="row" style="height: 10px;"></div>
			<div class="row">
				<label class="col-md-2" style="line-height: 35px;">&nbsp;&nbsp;&nbsp;&nbsp;用油类型&nbsp;<b
					style="color: red; font-size: 16px;">*</b>：
				</label>
				<div class="col-md-3">
						<c:if test="${order.customerType==1}">
							<span style="float: left;"><input type="radio" value="1"
							checked="checked" name="customerType">&nbsp;&nbsp;买油送车&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
							<span style="float: left;"><input type="radio" value="2"
							name="customerType">&nbsp;&nbsp;买油送油</span>
						</c:if>
						<c:if test="${order.customerType==2}">
						<span style="float: left;"><input type="radio" value="1"
							name="customerType">&nbsp;&nbsp;买油送车&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
							<span style="float: left;"><input type="radio" value="2" checked="checked"
							name="customerType">&nbsp;&nbsp;买油送油</span>
						</c:if>
				</div>
			</div>
			<div class="row" style="height: 10px;"></div>
			<div class="row">
				<label class="col-md-2" style="line-height: 35px;">&nbsp;&nbsp;返油分期数&nbsp;<b
					style="color: red; font-size: 16px;">*</b>：
				</label>
				<div class="col-md-3">
					<select class="form-control" name="backByMonth" id="backByMonth" value="${order.backByMonth}" >
					<c:if test="${order.backByMonth ==6}">
							<option value="6" selected="selected">六期</option>
							<option value="12">十二期</option>
							<option value="18">十八期</option>
							<option value="24">二十四期</option>
							<option value="30">三十期</option>
						</c:if>
						<c:if test="${order.backByMonth ==12}">
							<option value="6" >六期</option>
							<option value="12" selected="selected">十二期</option>
							<option value="18">十八期</option>
							<option value="24">二十四期</option>
							<option value="30">三十期</option>
						</c:if>
						<c:if test="${order.backByMonth ==18}">
							<option value="6" >六期</option>
							<option value="12">十二期</option>
							<option value="18" selected="selected">十八期</option>
							<option value="24">二十四期</option>
							<option value="30">三十期</option>
						</c:if>
						<c:if test="${order.backByMonth ==24}">
							<option value="6" >六期</option>
							<option value="12">十二期</option>
							<option value="18">十八期</option>
							<option value="24" selected="selected">二十四期</option>
							<option value="30">三十期</option>
						</c:if>
						<c:if test="${order.backByMonth ==30}">
							<option value="6" >六期</option>
							<option value="12">十二期</option>
							<option value="18">十八期</option>
							<option value="24">二十四期</option>
							<option value="30" selected="selected">三十期</option>
						</c:if>
					</select>
				</div>
			</div>
			<div class="row" style="height: 10px;"></div>
			<div class="row">
				<label class="col-md-2" style="line-height: 35px;">&nbsp;&nbsp;&nbsp;&nbsp;充油金额&nbsp;<b
					style="color: red; font-size: 16px;">*</b>：
				</label>
				<div class="col-md-3">
					<input type="text" class="form-control newmer"
						name="inputOilAmount" placeholder="请输入充油金额" value="${order.inputOilAmount}" id="">
				</div>
			</div>
			<div class="row" style="height: 10px;"></div>
			<div class="row">
				<label class="col-md-2" style="line-height: 35px;">&nbsp;&nbsp;&nbsp;&nbsp;赠送金额&nbsp;<b
					style="color: red; font-size: 16px;">*</b>：
				</label>
				<div class="col-md-3">
					<input type="text" class="form-control newmer"
						name="donationAmount" placeholder="请输入赠送金额" value="${order.donationAmount}" id=""
						oninput="changeY()">
				</div>
			</div>
			<div class="row">
				<label class="col-md-2" style="line-height: 35px;">&nbsp;&nbsp;&nbsp;&nbsp;您的总金额&nbsp;<b
					style="color: red; font-size: 16px;">*</b>：
				</label>
				<div class="col-md-3" id="showRMB"></div>
			</div>
			<div class="row" style="height: 10px;"></div>
			<div class="row" style="height: 10px;"></div>
			<div class="row">
				<label class="col-md-2" style="line-height: 35px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;备注：</label>
				<div class="col-md-3">
					<textarea rows="5" cols="41" name="remarks" id="remarks" >
                        	${order.remarks}
                        </textarea>
				</div>
			</div>
			<div class="row" style="">
				<div
					style="width: 14%; height: 30px; display: inline-block; margin-left: 10%; margin-top: 20px;">
					<input type="button" class="btn offline_serch_hide"
						style="margin-right: 30px; background: #18BC9C; color: #fff; border-color: #18BC9C;"
						value="修改" id="submitButton"> <input type="button"
						class="btn offline_serch_hide"
						style="margin-right: 30px; background: #999; color: #fff; border-color: #999; display: none;"
						value="修改中。。。" disabled="disabled" id="submitShow">
				</div>
				<div
					style="width: 14%; height: 30px; display: inline-block; margin-left: 0%; margin-top: 20px;">
					<input type="button" class="btn offline_serch_hide"
						style="margin-right: 30px; background: #fff; color: #555; border-color: #C9C9C9;"
						value="返回" id="submitButton"  onclick="history.go(-1)" > 
				</div>
			</div>
			<div style="width: 100%; height: 15px;"></div>
		</form>
	</div>
</body>
</html>